﻿namespace ApiTemplate.IApplication
{
    /// <summary>
    /// 调度任务应用服务
    /// </summary>
    public interface ISchedulerApplication
    {
        /// <summary>
        /// 添加一个定时任务
        /// </summary>
        /// <param name="input">添加定时任务的入参</param>
        /// <returns>是否添加成功</returns>
        Task<bool> AddAsync(AddSchedulerTaskInput input);

        /// <summary>
        /// 修改定时任务
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<bool> UpdateAsync(UpdateSchedulerTaskInput input);

        /// <summary>
        /// 获取单个定时任务
        /// </summary>
        /// <param name="id">任务id</param>
        /// <returns></returns>
        Task<GetSchedulerTaskOutput> GetAsync(string id);

        /// <summary>
        /// 暂停任务
        /// </summary>
        /// <param name="input">要操作的任务id集合</param>
        /// <returns></returns>
        Task<bool> PauseTask(BaseGuidListInput input);

        /// <summary>
        /// 恢复任务
        /// </summary>
        /// <param name="input">要操作的任务id集合</param>
        /// <returns></returns>
        Task<bool> RenewTaskAsync(BaseGuidListInput input);

        /// <summary>
        /// 删除任务
        /// </summary>
        /// <param name="input">要操作的任务id集合</param>
        /// <returns></returns>
        Task<bool> DeleteAsync(BaseGuidListInput input);

        /// <summary>
        /// 获取定时任务列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<PageResult<GetSchedulerTaskPageOutput>> GetPageResultAsync(GetSchedulerTaskPageInput input);

        /// <summary>
        /// 获取指定任务的执行日志
        /// </summary>
        /// <param name="taskId">任务id</param>
        /// <returns></returns>
        Task<List<SchedulerTaskLog>> GetTaskLogAsync(string taskId);

        /// <summary>
        /// 初始化调度任务
        /// </summary>
        void InitSchedulerTask();
    }
}
